package com.acoffee.controller;

import com.acoffee.pojo.User;
import com.acoffee.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * @author acoffee
 * @create 2021-11-22 20:57
 */
@Controller
@RequestMapping("/acoffee")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping(value = "/user")
    public ModelAndView queryAll(){
        List<User> users = userService.queryAll();
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("msg",users);
        modelAndView.setViewName("success");
        return modelAndView;
    }
}
